#define _CRT_SECURE_NO_WARNINGS 1
#pragma once
struct ListNode* midSList(struct ListNode* head)
{
	struct ListNode* slow = head; struct ListNode* fast = head;
	while (fast && fast->next)
	{
		slow = slow->next;
		fast = fast->next->next;
	}
	return slow;
}
struct ListNode* resverseSList(struct ListNode* head)
{
	struct ListNode* cur = head;
	struct ListNode* newhead = NULL;
	while (cur)
	{
		struct ListNode* next = cur->next;
		cur->next = newhead;
		newhead = cur;
		cur = next;
	}
	return newhead;
}
bool isPalindrome(struct ListNode* head) {
	struct ListNode* midListNode = midSList(head);
	struct ListNode* resverseListNode = resverseSList(midListNode);
	while (resverseListNode)
	{
		if (head->val != resverseListNode->val)
		{
			return false;
		}
		else
		{
			head = head->next;
			resverseListNode = resverseListNode->next;
		}
	}
	return true;
}